<?php
/* OpenBIBLIO -- A library administration web interface
 * Copyright (C) 2011-     Laurent Luyssen   <big.lol13@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
session_start();
include_once("includes/db.inc");
include_once("includes/functions.inc");
include_once("includes/session.inc");

if (!SessionValide ()) {
	header("Status: 403 Forbidden");
	exit();
}

$request = "SELECT id, nom FROM livres ORDER BY nom ASC";
$result  = biblio_db_query($request);
if (!result) { 
	print "PROBLEME : " .biblio_db_error() . "<br>$request"; 
	exit();
}

echo "<table CELLPADDING=5><th>ID</th><th>Title</th><th>Result</th>";
while ($row = biblio_db_fetch_array($result)) {      
	$liv_id = $row['id'];           
	$title = format_title($row['nom']);  
	echo "<tr><td>$liv_id</td><td>$title</td>"; 
	
	if ($title != $row['nom']) {
		$request = "UPDATE livres SET nom=\"$title\" WHERE id=$liv_id";   
	    $result2 = biblio_db_query($request);
	    if (!result2)
	    	echo "<td> Error : $request: " .biblio_db_error()."</td>";
	    else
	    	echo "<td>Updated</td>";
	}
	else 
		echo "<td></td>";
	echo "</tr>";       
}
echo "</table>";


